package com.gitee.wsl.mathematics.geometry.d2.circle

import com.gitee.wsl.mathematics.coordinate.d2.Coordinate2
import com.gitee.wsl.mathematics.geometry.d2.CloseShape2d
import com.gitee.wsl.mathematics.geometry.d2.circle.ext.times
import com.gitee.wsl.mathematics.geometry.d2.line.LineShape2d
import com.gitee.wsl.mathematics.interpolator.Ratio
import com.gitee.wsl.mathematics.interpolator.ext.toRatio


interface SliceSegment2d<N:Number,V: Coordinate2<N, V>,S: CircleShape2d<N, V>>: CircleSegment2d<N, V, S>,CloseShape2d<N,V>{

    val outerRatio: Ratio
        get() = (innerRadius / outerRadius).toRatio()

    val innerRadius get() = parent.radius

    val outerRadius:N

    val innerCircleSegment get() = parent.createSegment(startAngle, sweepAngle)

    val outerCircleSegment get() = (parent * outerRatio).createSegment(startAngle, sweepAngle)

    fun createLine(a:V,b:V): LineShape2d<N, V>

    val leftLine get() = createLine(outerCircleSegment.start,innerCircleSegment.start)

    val rightLine get() = createLine(outerCircleSegment.end,innerCircleSegment.end)

    override val center: V
        get() = parent.center

     override val area: N
        get() = outerCircleSegment.area - innerCircleSegment.area

     override val perimeter: N
        get() = outerCircleSegment.perimeter + innerCircleSegment.perimeter - innerRadius * 4

    override fun containsPoint(p: Coordinate2<N, *>): Boolean = outerCircleSegment.containsPoint(p) && !innerCircleSegment.containsPoint(p)
}